<?php

/**
 * Created by Sublime.
 * User: tchenym
 * Date: 2018/08/21
 * Time: 上午午10:25
 */
class Return_model extends CI_Model
{

    public function __construct()
    {
        $this->load->database();
        $this->load->helper("common");
        $this->load->model('customer_model');
    }

    //返回成功信息
    private function sendOk($data)
    {

        $ret['code'] = 2000;
        $ret['msg']  = '';
        $ret['data'] = $data;
        send_json($ret);
    }

    //返回参数失败信息
    private function requireRes($s, $r)
    {

        if ($r) {
            if (!$s) {
                send_json(
                    array('code' => 4004, 'msg' => $r, 'data' => '')
                );
            }
        } else {
            if (is_array($s)) {
                foreach ($s as $v) {
                    $this->requireRes($v, '');
                }
            } else {
                if (!$s) {
                    send_json(
                        array('code' => 4000, 'msg' => '参数错误', 'data' => '')
                    );
                }
            }
        }
    }
}
